import { Router } from '@angular/router';
import { ErrorHandler, Injectable, Injector } from '@angular/core';

@Injectable()
export class GlobalExceptionErrorHandler implements ErrorHandler {
  private router: Router;

  constructor(injector: Injector) {
    setTimeout(() => this.router = injector.get(Router));
  }

  handleError(error) {
    console.log('globalExceptionHandler | hanldeError...');
    this.router.navigate(['/error']);
  }
}
